package com.leetcode.bit;

/**
 * @author Dennis Li
 * @date 2020/7/21 15:51
 */
public class HasAlternatingBits_693 {

    public boolean hasAlternatingBits(int n) {
        return Integer.bitCount((n ^ (n >> 1)) + 1) == 1;
    }

}
